{% extends "master.html" %}
{% block subtitle %} - 主面板 - 财务管理 - 更新账户{% endblock %}

{% block extJS %}
<script language="JavaScript" type="text/javascript">
//<![CDATA[
    function toSubmit(){
        var msg = [];
        clearMsg();
        $(".err").removeClass('err');
        
        if(!$("#name").val()){
            msg.push('请填写商店的账户名称！');
            $("#name").addClass('err');
        }
        
        if(!$("#bankID").val()){
            msg.push('请填写商店的账户银行！');
            $("#bankID").addClass('err');
        }
        
        if(!$("#code").val()){
            msg.push('请填写商店的账户号码！');
            $("#code").addClass('err');
        }
        
        if(!$("#currencyID").val()){
            msg.push('请填写商店的账户货币！');
            $("#currencyID").addClass('err');
        }
        
        if(!$("#paytypeID").val()){
            msg.push('请填写商店的支付方式！');
            $("#paytypeID").addClass('err');
        }
        
        if(!$("#owner").val()){
            msg.push('请填写商店的账户拥有人！');
            $("#owner").addClass('err');
        }
        
        if(msg.length > 0){
            alertError(msg);
            return false;
        }else{
            $("form").submit();
        }
    }

     function toCancel(){
         redirect_alert("{{MSG_LEAVE_WITHOUT_SAVING}}","{{url_for('.view',action='account')}}");
    }
//]]>
 </script>
{% endblock %}

{% block main %}
<div class="container">
    <div class="row">
        <ol class="breadcrumb">
          <li><a href="{{url_for('bpRoot.view')}}">主面板</a></li>
          <li class="active">财务管理</li>
        </ol>
    </div>
    <div class="row">
        <div class="btn-toolbar pull-right">
            <div class="btn-group"><button class="btn btn-primary" onclick="toSubmit()">{{BTN_SUBMIT}}</button></div>
            <div class="btn-group"><button class="btn btn-inverse" onclick="toSubmit()">{{BTN_CANCEL}}</button></div>
        </div>
    </div>
    <div class="row">
        <form class="" method='POST' action="{{url_for('bpFin.view',action='updateAccount')}}"  enctype="multipart/form-data">
        <input type="hidden" name="id" value="{{obj.id}}"/>
        <fieldset>
            <legend>账户信息</legend>
                <div>
                    <div class="col-md-4">
                        <div class="control-group">
                            <label class="control-label"><label for="name">账户名称</label></label>
                            <div class="controls"><input type="text" name="name" id="name" value="{{obj.name}}"/></div>
                        </div>
                        <div class="control-group">
                            <label class="control-label"><label for="code">账户银行</label></label>
                            <div class="controls">
                                {{mymacros.select('bankID',list=getMaster('Bank','name'),value=obj.bankID)}}
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label"><label for="code">账户号码</label></label>
                            <div class="controls"><input type="text" name="code" id="code" value="{{obj.code|f}}"/></div>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="control-group">
                            <label class="control-label"><label for="owner">账户拥有人</label></label>
                            <div class="controls"><input type="text" name="owner" id="owner" value="{{obj.owner|f}}"/></div>
                        </div>
                        <div class="control-group">
                            <label class="control-label"><label for="currencyID">账户货币</label></label>
                            <div class="controls">
                                <select name="currencyID" id="currencyID">    
                                    {% for c in getMaster('Currency') %}
                                        {% if c.id == obj.currencyID %} 
                                            <option value="{{c.id}}" selected="selected">{{c}}</option>
                                        {% else %}
                                            <option value="{{c.id}}">{{c}}</option>
                                        {% endif %}
                                    {% endfor %}
                                </select>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label"><label for="paytypeID">支付方式</label></label>
                            <div class="controls">
                                <select name="paytypeID" id="paytypeID">
                                    {% for p in getMaster('Paytype') %}
                                        {% if p.id == obj.paytypeID %}
                                            <option value="{{p.id}}" selected="selected">{{p}}</option>
                                        {% else %}
                                            <option value="{{p.id}}">{{p}}</option>
                                        {% endif %}
                                    {% endfor %}
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="control-group">
                            <label class="control-label"><label for="amount">余额</label></label>
                            <div class="controls"><input type="text" name="amount" id="amount" value="{{obj.amount}}" class="num"/></div>
                        </div>
                        <div class="control-group">
                            <label class="control-label"><label for="remark">备注</label></label>
                            <div class="controls"><textarea name="remark" id="remark">{{obj.remark|f}}</textarea></div>
                        </div>
                    </div>
                </div>
        </fieldset>
        </form>
    </div>
</div>
{% endblock %}